package com.lznAdmin.system.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lznAdmin.system.entity.SysPermission;
import com.lznAdmin.system.entity.SysUser;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @program: lzn-manage-parent
 * @description:
 * @author: lzn
 * @create: 2021-09-02 11:22
 **/

@Mapper
public interface SysUserMapper extends BaseMapper<SysUser> {


    IPage<SysUser> selectUserPage(Page<SysUser> page, @Param("sysUser") SysUser sysUser);

    List<Long> getNavMenuIds(Long userId);

    List<SysUser> listByMenuId(Long menuId);

    List<SysPermission> selectUserPermissions(Long userId);

    List<SysUser> getRoleList();

    @Insert("INSERT INTO `sys_user_role` (`id`,`user_id`, `role_id`) VALUES (#{ID},#{uid}, #{roleId})")
    int saveUserRole(Long ID, Long uid, Long roleId);

    @Update("UPDATE `sys_user_role` SET `user_id` = #{uid}, `role_id` = #{roleId} WHERE `id` = 3")
    int updateUserRole(Long uid, Long roleId);

    @Delete("DELETE FROM sys_user_role WHERE user_id = #{uid}")
    int deleteUserRole(Long uid);
}
